define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'union/cashout/index',
                    table: 'guild_cash_out',
                },
                commonSearch: true,
                searchFormVisible: true,
                visible: false,
                showToggle: false,
                showColumns: false,
                search:false,
                showExport: true,
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                columns: [
                    [

                        {field: 'amount', title: __('提现金额')},
                        {field: 'service_charges', title: __('手续费')},
                        {field: 'actual_amount', title: __('实际到账')},
                        {field: 'out_type', title: __('支付方式'),searchList: {'1' : '支付宝','2' :'银行卡'}, formatter: Table.api.formatter.normal},
                        {field: 'username', title: __('用户名')},
                        {field: 'idcard', title: __('身份证号')},
                        {field: 'bank_name', title: __('银行名称')},
                        {field: 'payment', title: __('支付宝账号/银行卡号')},
                        {field: 'status', title: __('状态'),searchList: {'0' : '审核打款中','1' :'已打款','2':'审核打款失败','3':'审核通过,待打款'}, formatter: Table.api.formatter.normal},
                        {
                            field: 'created_at',
                            title: __('申请时间'),
                            formatter: Table.api.formatter.datetime, datetimeFormat:"YYYYMMDD",
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                        },
                        {
                            field: 'updated_at',
                                title: __('审核打款时间'),
                            formatter: Table.api.formatter.datetime, datetimeFormat:"YYYYMMDD",
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                        },
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});